package xyz.ddlnt.servicemq.listener;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import xyz.ddlnt.model.dto.UserContentInteractionDTO;
import xyz.ddlnt.servicemq.service.PostCommentService;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/28 2:57
 */
@Slf4j
@Component
public class PostCommentListener {
    @Resource
    private PostCommentService postCommentService;

    /**
     * 一级评论的回复数+1
     * @param id
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "comment_count_plus_one"),
            exchange = @Exchange(name =  "usr.post_comment"),
            key = "comment_count_plus_one"
    ))
    public void commentCountPlusOne(Long id) {
        postCommentService.commentCountPlusOne(id);
        log.info("一级评论的回复数+1");
    }
}
